
clear
clc
clf

xs = -3:3;
ys = xs.^2;
points = [xs' ys'];
Stops.getInstance.init(points,1000*generate_distances(points),ones(1,length(xs)))

%% Generacja danych
kmeans_test1;

%% Inicjalizacja obiektu przystankow

% koszt to dlugosc, waga to ilosc osob na przystanek z k_mean obliczone
Stops.getInstance.init(center_of_cluster(:,1:2),generate_distances(center_of_cluster(:,1:2)),center_of_cluster(:,3))

%% Tworzenie populacji
PA2 = PopulationAwithMutation( 50, SimpleIndividual );

PA2.compute_objectives
PA2.sort();

PA2.best;


[he,hv,ht] = PA2.best.disp_connections;

%hold all

%% Zycie
tic;
generations = 200;
progress = zeros(1,generations +1);
progress(1) = PA2.best.objective_value;
for k=1:generations
    PA2.to_next_generation();
    
    PA2.compute_objectives();
    PA2.sort();
    PA2.best();
    progress(k+1) = PA2.best.objective_value;
end
toc;
%% Wynik

delete(he);
delete(hv);
delete(ht);
[he,hv,ht] = PA2.best.disp_connections;

%% Najlepszy znaleziony
delete(he);
delete(hv);
delete(ht);
PA2.best_of_all.disp_connections;

%% Postep
clf;
plot(progress);



    